<?php
declare (strict_types = 1);

namespace app\controller\v1;

use app\model\AddressRegion;
use app\model\Banner;
use app\model\PageDescriptions;
use app\model\Products;
use app\service\ProductsService;
use think\Request;

class CommentController extends BaseAPIController
{
    //获取协议内容 agreement
    public function agreement()
    {
        return $this->success((new PageDescriptions())->getAgreement());
    }

    // 获取级联地址
    public function getArea()
    {
        $parentId = $this->request->get('parent_id', 0);
        $result = (new AddressRegion())->getChildrenByParentId($parentId);
        // 添加一个默认值
        array_unshift($result, ['area_id' => 0, 'area_name' => '请选择']);
        return $this->success($result);
    }

    //获取轮播图
    public function getBanner()
    {
        return $this->success((new Banner())->where('is_show', 1)->order('order_by','asc')->select()->toArray());
    }

    public function gridList()
    {
        return $this->success([
            'small'=>   [
                ['image'=>env('APP_URL').'/static/image/feiyi.png','link'=>''],
                ['image'=>env('APP_URL').'/static/image/coupon.png','link'=>'/sub_common/coupon/index']
            ],
            'medium'=>   ['image'=>env('APP_URL').'/static/image/jingqu.png','link'=>'/sub_tickets/spots/index']
        ]);
    }


    
}
